package com.cykj.page02.servlet;

import com.alibaba.fastjson2.JSON;
import com.cykj.page02.MyHttpRequest;
import com.cykj.page02.MyHttpResponse;
import com.cykj.page02.anno.ServletMapping;
import com.cykj.page02.dto.ResponseDTO;
import com.cykj.page02.service.impl.UserServiceImpl;

/**
 * @BelongsProject: hand-tomcat
 * @BelongsPackage: com.cykj.page01.servlet
 * @Author: 阿隆
 * @CreateTime: 2025-11-01 11:58
 * @Description: TODO
 * @Version: 1.0
 */
@ServletMapping("/insertStudent")
public class InsertStudentServlet extends BaseServlet {
    @Override
    void doGet(MyHttpRequest httpRequest, MyHttpResponse httpResponse) {
        //获取账号密码 参数
        String account = httpRequest.getRequestParamToKey("account");
        String password = httpRequest.getRequestParamToKey("password");
        String stuId = httpRequest.getRequestParamToKey("stuId");

        //UserServiceImpl userService = new UserServiceImpl();
        ResponseDTO dto = UserServiceImpl.getInstance().insertStudent(Integer.valueOf(stuId), account, password);

        httpResponse.write(JSON.toJSONBytes(dto));

    }

    @Override
    void doPost(MyHttpRequest httpRequest, MyHttpResponse httpResponse) {
        doGet(httpRequest, httpResponse);
    }
}
